/**
 * 
 */
package edu.towson.cosc603.coffeemaker;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * @author Xuraj
 *
 */
public class CoffeeMakerTest {
	
	CoffeeMaker coffeeMaker;
	Recipe recipe;
	
	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
		coffeeMaker = new CoffeeMaker();
		recipe = new Recipe();
		
		recipe.setName("Morning Roast");
		recipe.setPrice(5);
		recipe.setAmtChocolate(0);
		recipe.setAmtCoffee(5);
		recipe.setAmtMilk(1);
		recipe.setAmtSugar(3);
	}

	/**
	 * @throws java.lang.Exception
	 */
	@After
	public void tearDown() throws Exception {
	}

	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.CoffeeMaker#CoffeeMaker()}.
	 */
	@Test
	public void testCoffeeMaker() {
		coffeeMaker = new CoffeeMaker();
		assertEquals(4, coffeeMaker.getRecipes().length);
	}

	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.CoffeeMaker#addRecipe(edu.towson.cosc603.coffeemaker.Recipe)}.
	 */
	@Test
	public void testAddRecipe() {
		recipe.setName("Chocolate Coffee");
		recipe.setPrice(10);
		recipe.setAmtChocolate(5);
		recipe.setAmtCoffee(3);
		recipe.setAmtMilk(3);
		recipe.setAmtSugar(5);
		
		assertEquals("Chocolate Coffee", recipe.getName());
		assertEquals(10, recipe.getPrice());
		assertEquals(5, recipe.getAmtChocolate());
		assertEquals(3, recipe.getAmtCoffee());
		assertEquals(3, recipe.getAmtMilk());
		assertEquals(5, recipe.getAmtSugar());
		
	}

	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.CoffeeMaker#deleteRecipe(edu.towson.cosc603.coffeemaker.Recipe)}.
	 */
	@Test
	public void testDeleteRecipe() {
		coffeeMaker.addRecipe(recipe);
		assertEquals(true, coffeeMaker.deleteRecipe(recipe));
		
	}

	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.CoffeeMaker#editRecipe(edu.towson.cosc603.coffeemaker.Recipe, edu.towson.cosc603.coffeemaker.Recipe)}.
	 */
	@Test
	public void testEditRecipe() {
		
		coffeeMaker.addRecipe(recipe);
		
		Recipe recipe2 = new Recipe();
		recipe2.setName("Morning Roast");
		recipe2.setPrice(10);
		recipe2.setAmtChocolate(5);
		recipe2.setAmtCoffee(0);
		recipe2.setAmtMilk(8);
		recipe2.setAmtSugar(5);
		
		assertEquals(true, coffeeMaker.editRecipe(recipe, recipe2));
	}

	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.CoffeeMaker#addInventory(int, int, int, int)}.
	 */
	@Test
	public void testAddInventory() {
		assertEquals(true, coffeeMaker.addInventory(5, 5, 5, 10));
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.CoffeeMaker#addInventory(int, int, int, int)}.
	 */
	@Test
	public void testAddInventoryFail() {
		assertEquals(false, coffeeMaker.addInventory(-1, 5, 5, 10));
	}

	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.CoffeeMaker#checkInventory()}.
	 */
	@Test
	public void testCheckInventory() {
		coffeeMaker.addInventory(5, 5, 5, 5);
		Inventory inventory = coffeeMaker.checkInventory();
		assertEquals(20, inventory.getChocolate());
		assertEquals(20, inventory.getCoffee());
		assertEquals(20, inventory.getMilk());
		assertEquals(20, inventory.getSugar());
	}

	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.CoffeeMaker#makeCoffee(edu.towson.cosc603.coffeemaker.Recipe, int)}.
	 */
	@Test
	public void testMakeCoffee() {
		assertEquals(10, coffeeMaker.makeCoffee(recipe, 15));
	}
	
	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.CoffeeMaker#makeCoffee(edu.towson.cosc603.coffeemaker.Recipe, int)}.
	 */
	@Test
	public void testMakeCoffeeFail() {
		assertEquals(3, coffeeMaker.makeCoffee(recipe, 3));
	}

	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.CoffeeMaker#getRecipes()}.
	 */
	@Test
	public void testGetRecipes() {
		
	}

	/**
	 * Test method for {@link edu.towson.cosc603.coffeemaker.CoffeeMaker#getRecipeForName(java.lang.String)}.
	 */
	@Test
	public void testGetRecipeForName() {
		coffeeMaker.addRecipe(recipe);
		Recipe recipe2 = coffeeMaker.getRecipeForName("Morning Roast");
		assertEquals("Morning Roast", recipe2.getName());
	}

}
